package org.cyz.tools.core.assembly.toast;

import lombok.Builder;
import lombok.Data;
import org.thehecklers.monologfx.MonologFX;
import org.thehecklers.monologfx.MonologFXBuilder;
import org.thehecklers.monologfx.MonologFXButton;
import org.thehecklers.monologfx.MonologFXButtonBuilder;

/**
 * Copyright (C), 2022
 * FileName: Toast
 * Author:   chenyz
 * Date:     2022/1/15 PM9:59
 * Description: 弹窗
 */
@Data
@Builder
public class Toast {


    private String title="提示";
    private String message;
    private String icon="dialog_apply.png";
    private int delay_time=5;
    private MonologFXButton.Type type= MonologFXButton.Type.OK;

    public Toast title(String title){
        this.title=title;
        return this;
    }

    public Toast message(String message){
        this.message=message;
        return this;
    }

    public Toast delayTime(int delayTime){
        this.delay_time=delayTime;
        return this;
    }

    public Toast icon(String icon){
        this.icon=icon;
        return this;
    }

    public Toast type(MonologFXButton.Type type){
        this.type=type;
        return this;
    }

    public Toast create(){
        MonologFXButton mlb = MonologFXButtonBuilder.create()
                .defaultButton(true)
                //.icon("dialog_apply.png")
                .type(this.type)
                .build();
        MonologFX mono = MonologFXBuilder.create()
                .modal(true)
                .message(this.message)
                .titleText(this.title)
                .button(mlb)
                .buttonAlignment(MonologFX.ButtonAlignment.CENTER)
                .displayTime(this.delay_time)
                .build();
        MonologFXButton.Type retval = mono.show();
        System.out.println("Return value=" + retval);
        return this;
    }

}
